#include <iostream>
#include <cstring>

using namespace std;

const int N = 110;
int a[N][N];
bool st[N][N];
int n, x, y;
int ans, sum;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

void dfs(int cur_x, int cur_y)
{
	ans = max(sum, ans);
	
	for(int k = 0; k < 4; k++)
	{
		int cnt = 0;
		for(int step = 1; ; step++)
		{
			int next_x = cur_x + step * dx[k];
			int next_y = cur_y + step * dy[k];
			if(next_x < 1 || next_x > n || next_y < 1 || next_y > n) break;
			if(a[next_x][next_y] == 1) cnt++;
			else
			{
				if(cnt >= 1 && !st[next_x][next_y])
				{
					st[next_x][next_y] = true;
					sum += cnt + 1;
					dfs(next_x, next_y);
					sum -= cnt + 1;
					st[next_x][next_y] = false;
				}
				break;
			}
		}
	}
}

int main()
{
	cin >> n >> x >> y;
	for(int i =1; i <= n; i++)
	{
		for(int j =1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}
	st[x][y] = true;
	dfs(x, y);
	cout << ans <<	endl;
	return 0;
}
